package com.hqj.controller;

import com.hqj.entity.ResourceEntity;
import com.hqj.service.ResourceService;
import com.hqj.utils.ResultUtil;
import com.hqj.utils.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 黄啟军
 * @version 1.0
 * @date 2020/7/23 0023
 */
@RestController
@RequestMapping("/resource")
@Api(tags = "资源网站")
public class ResourceController {
    @Resource
    private ResourceService resourceService;
    @ApiOperation("资源网站接口")
    @RequiresAuthentication
    @GetMapping("/findAll")
    public ResultVO<List<ResourceEntity>> findAll(){
        List<ResourceEntity> all = resourceService.findAll();
        if(all.isEmpty()){
            return ResultUtil.error();
        }
        return ResultUtil.success(all);
    }
}
